try {
  const { type } = $event
  const gis = this.getApiPage().getApiWidgetByAliasName('三维组件')
  const queryManage = this.pageObj.getApiWidgetByAliasName('queryManage')?.widgetObj
  const publicParams = this.getApiPage().getVariables().find(v => v.name === 'panel_type')
  const search = this.getApiPage().getVariables().find(v => v.name === 'event_search')

  console.log('$event: => ', $event)
  if(type === 'page') {
    const params = {
      pageNum: $event.params,
      pageSize: 10,
      eventTitle: search.value
    }
    const title = $event.instanceName
    if (publicParams?.value === '1') {
      params.occurrencePlace = title
    } else if (publicParams?.value === '2') {
      params.eventType = title
    } else if (publicParams?.value === '3') {
      params.eventGrade = title
    } else {
      params.occurrencePlace = title
    }
    queryManage.queryList(params, $event).then(res => {
      console.log(res)
      if(res.success) {
        this.widgetObj.tree.pannelRerender(title, {dataSource: res.result.result})
      }
    })
  }else if(type === 'operation') {

    const { operation, data } = $event.params
    switch(operation.type) {
      case '再现': {
        window.parent.postMessage({ type: 'nav/style', pageName: '处置' }, document.referrer);
        var authTokenVar = this.getApiPage().getVariables().find(x => x.name == "AuthToken");
        this.getApiPage().navigateStage('759726721858535424', [{ name: 'screen_params', value: data}, { name: 'AuthToken', value: authTokenVar.value }])
      }
        break;
      case '评估':

        break;
      case '总结':
      {
        const timeline = this.getApiPage().getApiWidgetByAliasName('timelineVertical');
        const summary = this.getApiPage().getApiWidgetByAliasName('summary').widgetObj;
        timeline.hideWidget()
        this.pageObj.setVariables([{ name: 'timeline_event_id', value: data.id }])
        summary.show()
        $('#summary .file-box').text(summary.fileName)

        window.parent.postMessage({ type: 'nav/style', pageName: '总结' }, document.referrer);
      }
        break;
      case '人员':
      {
        const personManage = this.pageObj.getApiWidgetsByClassName('person-manage')
        personManage.forEach(v => v.showWidget())

      }
        break;
      case '详情': {
        const detail = this.getApiPage().getApiWidgetsByClassName('detail')
        const $form = this.getApiPage().getApiWidgetByAliasName('judge-content')
        const $img = this.getApiPage().getApiWidgetByAliasName('detail-img')
        const queryManage = this.pageObj.getApiWidgetByAliasName('queryManage')?.widgetObj
        const { eventDetails } = data || {};

        queryManage.queryDrillDetail(data.id).then(res => {
          const { xCoordinate, yCoordinate, zCoordinate } = res
          const formData = {
            ...res,
            occurrencePlace: xCoordinate + ',' + yCoordinate + ',' + zCoordinate,
            disableFlag: [ '未演练', '已演练', '演练中', '已解除' ][+res.disableFlag]
          }

          gis.widgetObj.setIconPosition({ right: 420, top: 100 })
          detail.forEach(v => v.showWidget())

          $form.widgetObj._option.dataSource = formData;
          $form.widgetObj._option.isDetail = true
          $form.widgetObj.render()


          var personCountVar = $($form.__box).find("#d-personCount");

          if (personCountVar && personCountVar[0]) {
            personCountVar[0].innerText = "当前参演人员" + (formData.personCount) + "位";
          }

          var drillStateVar = $($form.__box).find("#d-drillState");

          if (drillStateVar && drillStateVar[0]) {
            drillStateVar[0].innerText = formData.drillState;
          }

          const form = this.getApiPage().retrievePlugin('base-forms')
          // 编辑状态
          form.resetForm('form_19')
          // 详情状态
          form.resetForm('form_20')

          data.drillTime = `${data.startTime} 至 ${data.endTime}`
          form.setFormData('form_19', formData)

          if (eventDetails) {
            const info = JSON.parse(eventDetails)
            console.log('info', [{ data: [{ src: info?.thumbnailPath }] }])
            $img.widgetObj.setData([{ data: [{ src: info?.thumbnailPath }] }])
            $img.widgetObj.render()
          } else {
            $img.widgetObj.setData([{ data: [{ src: '' }] }])
            $img.widgetObj.render()
          }
        })
      }
        break;
      case '合并列表':
      {
        const eventTime = this.pageObj.getApiWidgetsByClassName('event-time');
        const merge_modals = this.pageObj.getApiWidgetsByClassName('event-merge');
        merge_modals.forEach(v => v.hideWidget());
        eventTime.forEach(v => v.showWidget());

        this.pageObj.setVariables([{ name: 'event_parentId', value: data.id }])
      }
        break;
      case '合并':
      {
        const merge_modals = this.pageObj.getApiWidgetsByClassName('event-merge')
        const eventTime = this.pageObj.getApiWidgetsByClassName('event-time');
        merge_modals.forEach(v => v.showWidget())
        eventTime.forEach(v => v.hideWidget());
      }
        break;
    }
  }
}catch (e) {
  console.error(e)
}
